Skip to content

ffi: validate fast 32-bit integer argument ranges - #64691

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-i32-bypass-validation
Open

ffi: validate fast 32-bit integer argument ranges#64691
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-i32-bypass-validation

Conversation

@trivikr

@trivikr trivikr commented Jul 23, 2026

Copy link
Copy Markdown
Member

Fixes: #64690

V8’s Fast API converts 32-bit integer arguments to int32 or uint32
using coercing and truncating conversions. Fast FFI signatures using
i32, int32, u32, or uint32 did not enable the JavaScript
integer-validation wrapper, so optimized calls could accept invalid
values that the generic FFI path rejects.

Add the signed and unsigned 32-bit type names to the Fast API validation
metadata and native validation-selection check, with regression coverage
for out-of-range and non-integer values.


Assisted-by: openai:gpt-5.6-sol

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Jul 23, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 23, 2026
@trivikr
trivikr force-pushed the ffi-i32-bypass-validation branch from 5cfc0ae to a5ff09c Compare July 23, 2026 06:58
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.16%. Comparing base (54a5095) to head (004d3fd).

Files with missing lines Patch % Lines
src/ffi/fast.cc 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64691      +/-   ##
==========================================
+ Coverage   90.14%   90.16%   +0.02%     
==========================================
  Files         744      744              
  Lines      242518   242523       +5     
  Branches    45685    45714      +29     
==========================================
+ Hits       218611   218677      +66     
+ Misses      15396    15337      -59     
+ Partials     8511     8509       -2     
Files with missing lines Coverage Δ
lib/internal/ffi/fast-api.js 92.14% <100.00%> (+7.75%) ⬆️
src/ffi/fast.cc 66.27% <0.00%> (-0.39%) ⬇️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 24, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 25, 2026

@ExE-Boss ExE-Boss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably also needs u(int)32:

Comment thread src/ffi/fast.cc Outdated
Comment thread lib/internal/ffi/fast-api.js
Add i32, int32, u32, and uint32 to Fast API integer validation so
optimized calls reject invalid values instead of allowing V8 to
coerce or truncate them.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.6-sol
@trivikr
trivikr force-pushed the ffi-i32-bypass-validation branch from a5ff09c to 004d3fd Compare July 27, 2026 01:07
@trivikr trivikr removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 27, 2026
@trivikr trivikr changed the title ffi: validate fast i32 argument ranges ffi: validate fast 32-bit integer argument ranges Jul 27, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 27, 2026
@trivikr
trivikr requested a review from ShogunPanda July 28, 2026 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: Fast FFI bypasses i32 range validation after V8 optimization

4 participants